#include <vector>
#include <set>
#include <iostream>
#include <unordered_map>
using namespace std;

vector<int> mygetRow(int rowIndex) {
    vector<vector<int>> ret;
    for(int i = 0; i < rowIndex+1; i++){
        vector<int> row(i+1, 1);
        for(int j = 1; j < i; j++){
            row[j] = ret[i-1][j-1] + ret[i-1][j];
        }
        ret.push_back(row);
    }
    return ret[rowIndex];
}

vector<int> getRow(int rowIndex) {
    vector<int> pre, cur;
    for (int i = 0; i <= rowIndex; ++i) {
        cur.resize(i + 1);
        cur[0] = cur[i] = 1;
        for (int j = 1; j < i; ++j) {
            cur[j] = pre[j - 1] + pre[j];
        }
        pre = cur;
    }
    return pre;
}

int main(){
    int numRows = 5;
    vector<int> out = getRow(numRows);
    return 0;
}